<?
include("session.php");
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="../webkit/utils/jquery.js"></script>
<script type="text/javascript" src="../webkit/utils/form.checker.js"></script>
<link type="text/css" rel="stylesheet" href="page.css"/> 
<body  bgcolor="#f4f4f4" style="margin:0px;" scroll=no>

<form name=f> 
<hr size=1>
<table width=100% cellspacing=1 cellpadding=3 id="basic_info_table"> 
	<tr>
        <td align=right nowrap width=30%>当前密码</td><td><input type='password' id="o_userpass" class='input' check='not_empty' warning='当前密码不能为空！'></td>  
	</tr>
	<tr>
        <td align=right nowrap>新设密码</td><td><input type='password' id="n_userpass" class='input' check='not_empty' warning='新设密码不能为空！'></td>  
	</tr>
	<tr>
        <td align=right nowrap>确认密码</td><td><input type='password' id="r_userpass" class='input' check='not_empty' warning='确认密码不能为空！'></td>  
	</tr>
</form>	

<table width=100% cellspacing=1 cellpadding=3>
	<tr>
		<td align=center>
		<hr size=1>
		<input type="button" id="btn_save" class="button" value="保存设置" onclick="save()">　　<input type="button" class="button" value="关闭窗口" onclick="parent.closeDlg()"></td>
	</tr>
</table>

<script type="text/javascript">
	var f = document.f;
	function save() { 
		if(FormChecker.doCheck(f)) {
			if($('#n_userpass').val() != $('#r_userpass').val()) {
				alert("密码确认不一致，请检查！");
				return false;
			}
			var new_pwd = $('#n_userpass').val();
			if(new_pwd.indexOf("'")>=0 || new_pwd.indexOf("\\")>=0) {
				alert("新密码中存在非法字符(单引号或斜杠)，请去掉后重试！");
				return false;
			}
			var params = {'n_userpass' : new_pwd, 'o_userpass' : $('#o_userpass').val()}
			$("#btn_save").val("请稍后..");
			$("#btn_save").attr("disabled", true);
			$.post("user_query.php?action=modify_pwd", params, function(data) {
				if(data.indexOf("ok") == 0) {
					alert("您的登录密码已修改成功!");
					parent.closeDlg();

				} else if(data == 'o_userpass_incorrect') {
					alert("当前密码验证失败，请确认后重试!");
					$("#btn_save").val("保存设置");
					$("#btn_save").attr("disabled", false);
					
				} else {  
					alert(data);
				}
			});
		}
	}; 


</script>
</body>
</html>